package com.abel.bigwater.kmgw.dao

import com.abel.bigwater.dataserver.model.FlowDataPojo
import org.springframework.data.mongodb.core.query.Query

interface FlowDao {

    fun saveFlowData(fd: FlowDataPojo, colName: String? = null)

    fun listFlowData(query: Query): MutableList<FlowDataPojo>?

    /**
     * update if exists; insert if not.
     */
    fun upsert(fd: FlowDataPojo, colName: String? = null): Long?

    /**
     * update and return count (may be 0 or 1)
     */
    fun updateSendCount(fd: FlowDataPojo): Long

    /**
     * delete specified flow.
     */
    fun removeFlowData(fd: FlowDataPojo): Long

    /**
     * 删除 daysBefore 以前的数据.
     */
    fun removeExpired(daysBefore: Int = 90): Long?

    /**
     * mark as 'sent' - they are not sent again.
     */
    fun markSent(fd: FlowDataPojo): Long?

    /**
     * fetch unsent in days - send them out then.
     */
    fun unsentList(days: Int = 3): MutableList<FlowDataPojo>?
}